package com.rx.mgt.dao;

import com.rx.mgt.dao.base.ManagementHibernateDaoBase;
import com.rx.mgt.domain.UserGroupDepartMent;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zxj on 2017/4/18.
 */
@Repository
public class UserGroupDepartMentDao extends ManagementHibernateDaoBase<UserGroupDepartMent, String> {

    @Transactional(readOnly = true)
    public List<UserGroupDepartMent> queryAllDepartmentsByGroupId(String pId) {
        String hql = "from UserGroupDepartMent um where um.user_quota_group_id=:groupId";
        Query query = template.getSessionFactory().getCurrentSession().createQuery(hql);
        query.setParameter("groupId",Long.valueOf(pId));
        return query.list();
    }
}
